package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单商品模型类
 * 对应数据库表：yoshop_order_goods
 */
@Data
@TableName("yoshop_order_goods")
@Schema(description = "订单商品实体")
public class OrderGoods {

    /**
     * 主键id
     */
    @TableId(value = "order_goods_id", type = IdType.AUTO)
    @Schema(description = "主键id")
    private Integer orderGoodsId;

    /**
     * 订单id
     */
    @TableField("order_id")
    @Schema(description = "订单id")
    private Integer orderId;

    /**
     * 商品id
     */
    @TableField("goods_id")
    @Schema(description = "商品id")
    private Integer goodsId;

    /**
     * 商品名称
     */
    @TableField("goods_name")
    @Schema(description = "商品名称")
    private String goodsName;

    /**
     * 商品封面图id
     */
    @TableField("image_id")
    @Schema(description = "商品封面图id")
    private Integer imageId;

    /**
     * 库存计算方式(10下单减库存 20付款减库存)
     */
    @TableField("deduct_stock_type")
    @Schema(description = "库存计算方式(10下单减库存 20付款减库存)")
    private Integer deductStockType;

    /**
     * 规格类型(10单规格 20多规格)
     */
    @TableField("spec_type")
    @Schema(description = "规格类型(10单规格 20多规格)")
    private Integer specType;

    /**
     * 商品sku标识
     */
    @TableField("spec_sku_id")
    @Schema(description = "商品sku标识")
    private String specSkuId;

    /**
     * 商品规格id
     */
    @TableField("goods_sku_id")
    @Schema(description = "商品规格id")
    private Integer goodsSkuId;

    /**
     * 商品规格
     */
    @TableField("goods_sku_spec")
    @Schema(description = "商品规格")
    private String goodsSkuSpec;

    /**
     * 商品规格信息
     */
    @TableField("goods_attr")
    @Schema(description = "商品规格信息")
    private String goodsAttr;

    /**
     * 商品详情
     */
    @TableField("content")
    @Schema(description = "商品详情")
    private String content;

    /**
     * 商品编码
     */
    @TableField("goods_no")
    @Schema(description = "商品编码")
    private String goodsNo;

    /**
     * 条形码
     */
    @TableField("bar_code")
    @Schema(description = "条形码")
    private String barCode;

    /**
     * 商品价格
     */
    @TableField("goods_price")
    @Schema(description = "商品价格")
    private BigDecimal goodsPrice;

    /**
     * 商品单价
     */
    @TableField("goods_money")
    @Schema(description = "商品单价")
    private BigDecimal goodsMoney;

    /**
     * 商品划线价
     */
    @TableField("line_price")
    @Schema(description = "商品划线价")
    private BigDecimal linePrice;

    /**
     * 商品重量(Kg)
     */
    @TableField("goods_weight")
    @Schema(description = "商品重量(Kg)")
    private Double goodsWeight;

    /**
     * 是否存在会员等级折扣
     */
    @TableField("is_user_grade")
    @Schema(description = "是否存在会员等级折扣")
    private Integer isUserGrade;

    /**
     * 会员折扣比例(0-10)
     */
    @TableField("grade_ratio")
    @Schema(description = "会员折扣比例(0-10)")
    private Integer gradeRatio;

    /**
     * 会员折扣的商品单价
     */
    @TableField("grade_goods_price")
    @Schema(description = "会员折扣的商品单价")
    private BigDecimal gradeGoodsPrice;

    /**
     * 会员折扣的总额差
     */
    @TableField("grade_total_money")
    @Schema(description = "会员折扣的总额差")
    private BigDecimal gradeTotalMoney;

    /**
     * 优惠券折扣金额
     */
    @TableField("coupon_money")
    @Schema(description = "优惠券折扣金额")
    private BigDecimal couponMoney;

    /**
     * 积分金额
     */
    @TableField("points_money")
    @Schema(description = "积分金额")
    private BigDecimal pointsMoney;

    /**
     * 积分抵扣数量
     */
    @TableField("points_num")
    @Schema(description = "积分抵扣数量")
    private Integer pointsNum;

    /**
     * 赠送的积分数量
     */
    @TableField("points_bonus")
    @Schema(description = "赠送的积分数量")
    private Integer pointsBonus;

    /**
     * 优惠活动价格
     */
    @TableField("discount_active_price")
    @Schema(description = "优惠活动价格")
    private BigDecimal discountActivePrice;

    /**
     * 购买数量
     */
    @TableField("total_num")
    @Schema(description = "购买数量")
    private Integer totalNum;

    /**
     * 商品总价(数量×单价)
     */
    @TableField("total_price")
    @Schema(description = "商品总价(数量×单价)")
    private BigDecimal totalPrice;

    /**
     * 实际付款价(折扣和优惠后)
     */
    @TableField("total_pay_price")
    @Schema(description = "实际付款价(折扣和优惠后)")
    private BigDecimal totalPayPrice;

    /**
     * 是否开启单独分销(0关闭 1开启)
     */
    @TableField("is_ind_dealer")
    @Schema(description = "是否开启单独分销(0关闭 1开启)")
    private Integer isIndDealer;

    /**
     * 分销佣金类型(10百分比 20固定金额)
     */
    @TableField("dealer_money_type")
    @Schema(description = "分销佣金类型(10百分比 20固定金额)")
    private Integer dealerMoneyType;

    /**
     * 分销佣金(一级)
     */
    @TableField("first_money")
    @Schema(description = "分销佣金(一级)")
    private BigDecimal firstMoney;

    /**
     * 分销佣金(二级)
     */
    @TableField("second_money")
    @Schema(description = "分销佣金(二级)")
    private BigDecimal secondMoney;

    /**
     * 分销佣金(三级)
     */
    @TableField("third_money")
    @Schema(description = "分销佣金(三级)")
    private BigDecimal thirdMoney;

    /**
     * 是否已评价(0否 1是)
     */
    @TableField("is_comment")
    @Schema(description = "是否已评价(0否 1是)")
    private Integer isComment;

    /**
     * 用户id
     */
    @TableField("user_id")
    @Schema(description = "用户id")
    private Integer userId;

    /**
     * 来源记录id
     */
    @TableField("goods_source_id")
    @Schema(description = "来源记录id")
    private Integer goodsSourceId;

    /**
     * 小程序id
     */
    @TableField("wxapp_id")
    @Schema(description = "小程序id")
    private Integer wxappId;

    /**
     * 分类（10商品，20赠品）
     */
    @TableField("is_type")
    @Schema(description = "分类（10商品，20赠品）")
    private Integer isType;

    /**
     * 是否发货（10未发货，20已发货）
     */
    @TableField("is_order_express")
    @Schema(description = "是否发货（10未发货，20已发货）")
    private Integer isOrderExpress;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @Schema(description = "创建时间")
    private Long createTime;

    /**
     * 物流id
     */
    @TableField("order_express_id")
    @Schema(description = "物流id")
    private Integer orderExpressId;

    /**
     * 是否删除
     */
    @TableField("is_delete")
    @Schema(description = "是否删除")
    @TableLogic
    private Integer isDelete;

    @Schema(description = "创建时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTimeFormat;


    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
        this.setCreateTimeFormat(LocalDateTime.ofEpochSecond(createTime, 0, java.time.ZoneOffset.ofHours(8)));
    }
} 